package Practice.P02;

import java.util.*;
import java.util.TreeSet;
// 排序方式一: 给每个牌添加数字索引
public class PokerGameOrder01 {
    static HashMap<Integer,String> hm = new HashMap<>();
    static ArrayList<Integer> list = new ArrayList<>();
    static {
        String[] color = {"♥","♠","♦","♣"};
        String[] number = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
        int serialNumber = 1;
        for (String n : number) {
            for (String c : color) {
                hm.put(serialNumber,c+n);
                list.add(serialNumber);
                serialNumber++;
            }
        }
        hm.put(serialNumber,"小王");
        list.add(serialNumber);
        serialNumber++;
        hm.put(serialNumber,"大王");
        list.add(serialNumber);
    }
    public PokerGameOrder01(){
        Collections.shuffle(list);
        TreeSet<Integer> lord = new  TreeSet<>();
        TreeSet<Integer> play1 = new TreeSet<>();
        TreeSet<Integer> play2 = new TreeSet<>();
        TreeSet<Integer> play3 = new TreeSet<>();
        for (int i = 0; i < list.size(); i++) {
            int serialNumber = list.get(i);
            if(i<=2){
                lord.add(serialNumber);
                continue;
            }
            if(i%3==0){
                play1.add(serialNumber);
            } else if (i%3==1) {
                play2.add(serialNumber);
            }else {
                play3.add(serialNumber);
            }
        }
        lookPoker("底牌",lord);
        lookPoker("玩家一",play1);
        lookPoker("玩家二",play2);
        lookPoker("玩家三",play3);
    }
    public void lookPoker(String name,TreeSet<Integer> ts){
        System.out.print(name+":");
        for (Integer serialNumber : ts) {
            String poker = hm.get(serialNumber);
            System.out.print(poker+" ");
        }
        System.out.println();
    }
    }




